package edu.scsu.csci.context;

import edu.scsu.csci.util.ReflectionUtil;


/**
 * <p>	All caching implementations of the should implement 
 * 		this interface.
 * 
 * @author Maqbool Khan
 * @since jdk 1.5
 * @see
 * @viz.diagram ContextCachingStratergy.tpx
 */
public interface ContextCachingStratergy<T> {
	
	/**
	 * <p>	cache the object.
	 * 
	 * @param object
	 */
	void cache(T object);
	
	/**
	 * Returns the object that has been cached.
	 * 
	 * @return
	 */
	T lookUp();
	
	
	/**
	 * <p>  A factory to create an instance of the caching stratergy configured for the application.
	 *
	 * @author Maqbool Khan
	 * @since jdk 1.5
	 * @see
	 */
	final public static class ContextCachingStratergyFactory	{
		
		/**
		 * Creates an instance of the caching stratergy configured for the application.
		 * 
		 * @param clazz
		 * @return
		 */
		public static ActionContext create(Class<?> clazz)	{
			return (ActionContext)ReflectionUtil.instantiate(clazz);
		}
	}
}
